package com.sky.controller.user;/*
@author sun
@date 24/07/19
@project IntelliJ IDEA
*/

import com.sky.result.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.RedisTemplate;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

// c端-店铺状态
@RestController
@RequestMapping("/user/shop")
@Slf4j
public class ShopUserController {

    private static final String KEY = "STOP_STATUS";

    @Autowired
    private RedisTemplate redisTemplate;

    // 获取c端 店铺状态
    @GetMapping("/status")
    public Result<Integer> getShopStatus() {
        Integer status = (Integer) redisTemplate.opsForValue().get(KEY);
        log.info("获取c端 店铺状态为:{}",status == 1 ? "start" : "stop");
        return Result.success(status);
    }
}
